﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleAppDemo {
    public class Factory : IDisposable {
        private StringBuilder sb = new StringBuilder();
        private List<int> list = new List<int>();
        public void MakeSomeGarbage()
        {
            for (int i = 0; i < 5000; i++)
            {
                sb.Append(i.ToString());
            }
        }
        ~Factory()
        {
            Dispose(false);
        }
        public void Dispose()
        {
            Dispose(true);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing) return;
            sb = null;
            GC.Collect();
            GC.SuppressFinalize(this);
        }
    }

    public class GenObj {
        ~GenObj()
        {
            Console.WriteLine("In Finalize method");
        }
    }
}
